#include "StarPos.h"
#include "global/GlobalDefine.h"

StarPos::StarPos(){

}
StarPos::~StarPos(){

}

StarPos* StarPos::create(CCPoint pos){
	StarPos* starPos = new StarPos();
	if(starPos && starPos->init(pos)){
		starPos->autorelease();
	}else{
		CC_SAFE_DELETE(starPos);
		starPos = NULL;
	}
	return starPos;
}

bool StarPos::init(CCPoint pos){
	bool bRet = false;
	do{
		CC_BREAK_IF(!BasePos::init(pos));

		bRet = true;
	}while(0);

	return bRet;
}

StarPos* StarPos::create(CCPoint pos,bool isDebug){
	StarPos* starPos = new StarPos();
	if(starPos && starPos->init(pos,isDebug)){
		starPos->autorelease();
	}else{
		CC_SAFE_DELETE(starPos);
		starPos = NULL;
	}
	return starPos;
}
bool StarPos::init(CCPoint pos,bool isDebug){
	bool bRet = false;
	do{
		CC_BREAK_IF(!BasePos::init(pos,isDebug));

		bRet = true;
	}while(0);

	return bRet;
}

void StarPos::draw(){
	if(m_isDebug){
		glLineWidth(5);

		CCPoint srcPoint = ccp(m_pos.x - SIZE_StarPos, m_pos.y - SIZE_StarPos);
		CCPoint destPoint = ccp(m_pos.x + SIZE_StarPos, m_pos.y + SIZE_StarPos);

		ccDrawRect(srcPoint,destPoint);

		glLineWidth(1);
	}
}

bool StarPos::isClickMe(CCPoint pos){
	CCPoint srcPoint = ccp(m_pos.x - SIZE_StarPos, m_pos.y - SIZE_StarPos);
	CCPoint destPoint = ccp(m_pos.x + SIZE_StarPos, m_pos.y + SIZE_StarPos);

	if(pos.x >= srcPoint.x && pos.y >= srcPoint.y
		&& pos.x <= destPoint.x && pos.y <= destPoint.y){
		return true;
	}
	return false;
}